package com.renli.service.impl;

import com.renli.bean.ResultJson;
import com.renli.mapper.ArchivesMapper;
import com.renli.service.ArchivesService;
import com.renli.vo.ArchivesVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

@Service
public class ArchivesServiceImpl implements ArchivesService {

    @Autowired
    private ArchivesMapper archivesMapper;


    /**
     * 员工明细
     * @param map
     * @return
     */
    @Override
    public ResultJson<List<ArchivesVo>> find(Map<String, Object> map) {
        ResultJson<List<ArchivesVo>> resultJson = new ResultJson<>();


        if (map == null) {
            map = new HashMap<>();
        }

        if (map.get("currentPage") == null || map.get("currentPage").equals("")) {
            map.put("currentPage", 1);
        }
        if (map.get("pageSize") == null || map.get("pageSize").equals("")) {
            map.put("pageSize", 6);
        }


        Integer start = (Integer) map.get("pageSize") * ((Integer) map.get("currentPage") - 1);
        map.put("start", start);

        List<ArchivesVo> list = archivesMapper.findInfo(map);
        resultJson.setSuccess("查询成功",list);
//        List<ArchivesVo> archivesVoList = archivesMapper.find(map);
        return resultJson;
    }
}
